<?php

namespace app\admin\model;

use app\admin\model\BaseModel;


class Site extends BaseModel
{

    protected $name = "site";
    protected $pk = "id";
    // 追加属性
    protected $append = [
        'status_title',
        'admin_title',
    ];
    protected $deleteTime = false;


    public function getStatusTitleAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = ['normal' => '正常', 'hidden' => '隐藏', 'unavailable' => '无效', '' => '未分配'];
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getAdminTitleAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['adminid']) ? $data['adminid'] : '');
        $admin = table('system_admin')->where(['id' => $data['adminid']])->find();
        return isset($admin['nickname']) ? $admin['nickname'] : '未分配';
    }
}
